New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(AsyncPipe): allow onError argument #7990
Conversation
23fb2fe
to
c30e1e2
Compare
what's the usage look like? something like
? |
@robwormald ya |
Hey @robwormald & @gdi2290, It seems a bit strange to me that one would put error handling in the UI.
PS: Just trying to get a better feel for the motivation behind thes PR. |
This reverts commit 390046d. CI fails for IE on win8. PR angular#7990
This reverts commit 390046d. CI fails for IE on win8. PR angular#7990
Any plans to fix this PR? |
@@ -1,4 +1,5 @@ | |||
import {isBlank, isPresent, isPromise, CONST} from 'angular2/src/facade/lang'; | |||
import {ListWrapper} from 'angular2/src/facade/collection'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this anymore
Why was this closed? |
@stevenjob Observable has |
doesn't catch require you to return an observable? An equivalent to .subscribe(_, handleError) is needed? |
You can use if/else style syntax:
(it's only available in ng4+) |
Returning an observable of false from a stream that is supposed to return user would break typescript and seems like a smell to me. I have seen people use
Since the async pipe is doing the same job as using subscribe it should handle all the same things as subscribe e.g. onNext, onError, onCompleted To handle all cases:
|
ok, you can return null/undefined
if you need all 3 callbacks just subscribe inside a component |
So the conclusion is: never use async pipes if you want to handle errors properly, specially if you want to display an error message sent from the server. |
A problem with AsyncPipe throwing errors is that it makes them uncatchable in jasmine tests as far as I can tell. If you are testing the error handling then you want the errors to make it to the template, but you don't want those errors to reach jasmine and cause the test to fail with Uncaught error. I had to work around this issue by patch AsyncPipe to not throw errors in my tests. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
feature
an error is thrown within the template
allow passing a onError callback
nope
closes feat(AsyncPipe): allow for error and/or complete callbacks as arguments to |async pipe #7539